home *** CD-ROM | disk | FTP | other *** search
/ Mac Expert 1995 Winter / Mac Expert - Winter 95.iso / Les fichiers / Communications / Divers / DinkClass ƒ / DC Scribble / DScribbleWind.c < prev    next >
Encoding:
Text File  |  1992-10-11  |  2.0 KB  |  104 lines  |  [TEXT/KAHL]

  1. /*
  2.     File:        DScribbleWind.c
  3.  
  4.     Written by:    Mark Gross
  5.  
  6.     Copyright:    © 1992 by Applied Technical Software, all rights reserved.
  7.     Use at your own risk.
  8.  
  9. */
  10. // This is the class definition of DScribbleWind
  11.  
  12. #include "DScribbleWind.h"
  13. #include "DScribbleDoc.h"
  14.  
  15.  
  16.  
  17. DScribbleWind::DScribbleWind(void)
  18. {
  19.     //stub
  20. }
  21.  
  22. DScribbleWind::~DScribbleWind(void)
  23. {
  24.     //stub
  25. }
  26.  
  27.  
  28.  
  29. Boolean DScribbleWind::Init(DDocument *doc, Boolean hasColorWindows)
  30. {
  31.     Boolean inheritedSuccess;
  32.     PicHandle        thePict;
  33.  
  34.     thePict = ((DScribbleDoc *) doc)->fPict;
  35.     
  36.     fPenSize = 1;
  37.     fPenPat = patBlack;
  38.     
  39.     inheritedSuccess = inherited :: Init(doc, hasColorWindows);
  40.     if(thePict != NULL)
  41.     {
  42.         fVMin = 0;
  43.         fVMax = (**thePict).picFrame.bottom - (**thePict).picFrame.top;
  44.         
  45.         fHMin = 0;
  46.         fHMax = (**thePict).picFrame.right - (**thePict).picFrame.left;
  47.     }
  48.  
  49.     return (inheritedSuccess);
  50. }// end of init function
  51.  
  52.  
  53. void    DScribbleWind::DoContent(EventRecord* theEvent)
  54. {    
  55.     Rect contents;
  56.     Point    newPoint;
  57.     PicHandle thePict;
  58.     
  59.     FocusOnWindow();
  60.     GlobalToLocal(&theEvent->where);
  61.     GetContentRect(&contents);
  62.     if(PtInRect(theEvent->where, &contents))
  63.     {
  64.         PenSize(fPenSize, fPenSize);
  65.         
  66.         if(fPenPat == patBlack)
  67.             PenPat(black);
  68.         if(fPenPat == patGray)
  69.             PenPat(gray);
  70.         if(fPenPat == patWhite)
  71.             PenPat(white);
  72.         FocusOnContent();
  73.         GetMouse( &newPoint);
  74.         MoveTo(newPoint.h, newPoint.v);
  75.         do
  76.         {
  77.             GetMouse( &newPoint);
  78.                 LineTo(newPoint.h, newPoint.v);
  79.  
  80.         } while(StillDown());
  81.         
  82.         fDoc->fNeedToSave = TRUE;
  83.         thePict = ((DScribbleDoc *) fDoc)->fPict;
  84.         if( thePict != NULL)
  85.             KillPicture( thePict);
  86.             
  87.         thePict = OpenPicture(&fWindowPtr->portRect);
  88.         CopyBits(&fWindowPtr->portBits, &fWindowPtr->portBits,
  89.                 &fWindowPtr->portRect, &fWindowPtr->portRect, srcCopy, NULL);
  90.         ClosePicture();
  91.         ((DScribbleDoc *) fDoc)->fPict = thePict;
  92.     }// end if in content rect
  93.     else
  94.                 ScrollClick(theEvent);
  95.  
  96. }// end of DoContent function
  97.  
  98.  
  99. void    DScribbleWind::Draw(Rect *r)
  100. {
  101.     if(((DScribbleDoc *) fDoc)->fPict != NULL)
  102.         DrawPicture(((DScribbleDoc *) fDoc)->fPict, &( (*(((DScribbleDoc *) fDoc)->fPict))->picFrame ) );
  103. }
  104.